//
//  MyCell_1.m
//  UI09_5_Cell高度根据图片大小调整
//
//  Created by Scott on 15/5/8.
//  Copyright (c) 2015年 www.lanou3g.com 蓝欧3G. All rights reserved.
//

#import "MyCell_1.h"

@interface MyCell_1 ()

@property (nonatomic, retain) UIImageView *cellImageView;

@end

@implementation MyCell_1

-(void)dealloc
{
    [_cellImageView release];
    [_cellImage release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    NSLog(@"%s, %d", __func__, __LINE__);

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.cellImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.cellImageView];
        [_cellImageView release];
        
    }
    
    return  self;
}

- (void)layoutSubviews
{
    NSLog(@"%s, %d", __func__, __LINE__);
    [super layoutSubviews];
    
    self.cellImageView.image = [UIImage imageNamed:self.cellImage];
    self.cellImageView.frame = self.contentView.frame;
    
}


#pragma mark - 根据图片信息计算高度
+ (CGFloat)heightWithImage:(NSString *)imageName
{
    /* 根据image名字创建image对象, image的size属性记录照片的原始的大小信息, 按照新的宽度比例计算高度*/
    UIImage *image = [UIImage imageNamed:imageName];

    CGFloat newHeight = image.size.height / image.size.width * 375;
    
    /* 返回高度 */
    return newHeight;
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
